import axios from 'axios'
import { error } from '@/common/tool/message.js'
const service = axios.create({
    baseURL: "/api"
})

// 添加请求拦截器
service.interceptors.request.use(function (config) {

    config.headers['path'] = window.sessionStorage.getItem('path') || ""
    config.headers['adminuid'] = window.localStorage.getItem('admin_uid') || ""
    config.headers['admintoken'] = window.localStorage.getItem('admin_token') || ""
    config.headers['adminusername'] = window.localStorage.getItem('admin_username') || ""
    return config

}, function (err) {

    error(err.message)
    return Promise.reject(err)

});

// 添加响应拦截器
service.interceptors.response.use(function (response) {
    return response;
}, function (err) {
    error(err.message)
    return Promise.reject(err.message);
})

// get请求
export function request_get(path, data) {
    return service.get(path, data)
}

// post请求
export function request_post(path, data) {
    return service.post(path, data)
}




